package com.yaoyanshe.trialfield.common.base;

import android.view.View;

/**
 * <p>description:</p>
 * <p>created on: 2019/11/6 14:36</p>
 *
 * @author tck
 * @version 1.0
 */
public abstract class AbstractYYSCustomClickListener implements View.OnClickListener {

    private long mLastClickTime;
    private long timeInterval = 900L;

    public AbstractYYSCustomClickListener() {

    }

    public AbstractYYSCustomClickListener(long interval) {
        this.timeInterval = interval;
    }

    @Override
    public void onClick(View v) {
        long nowTime = System.currentTimeMillis();
        if (nowTime - mLastClickTime > timeInterval) {
            // 单次点击事件
            onSingleClick(v);
            mLastClickTime = nowTime;
        } else {
            // 快速点击事件
            onFastClick(v);
        }
    }

    /**
     * 单次点击事件
     */
    protected abstract void onSingleClick(View view);

    /**
     * 快速点击事件
     */
    protected void onFastClick(View view){

    }
}
